package com.citywy.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class LoginController {
    @RequestMapping("/login")
    public String login(Model model) throws Exception{
        return "/WEB-INF/pages/login";
    }

    //登陆提交
    //userid:用户账号 pwd:密码
    @RequestMapping("/loginsubmit")
    public String loginsubmit(HttpSession session,String userid,String pwd) throws Exception{
        //向session记录用户身份信息
        session.setAttribute("activeUser",userid);
        return "/WEB-INF/pages/main";
    }

    @RequestMapping("/logout")
    public String logout(HttpSession session) throws Exception{
        //session过期
        session.invalidate();
        return "redirect:/index.jsp";
    }

}
